import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import AboutViewVue from '../views/AboutView.vue'
import ChildVue from '@/views/Child.vue'
import Material from '@/views/Material.vue'
import Cso from '@/views/Cso.vue'
import CsoSub from '@/views/Cso-sub.vue'

import Layour from '@/layout/layout.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: Layour,
      redirect: '/main',
      children: [
        {
          path: 'main',
          name: 'main',
          component: HomeView
        },
        {
          path: 'material:pathMatch(.*)',
          name: 'material',
          meta: {
            id: 'material-app'
          },
          component: Material
        },
        {
          path: 'cso:path(.*)',
          name: 'cso',
          meta: {
            id: 'cso-app'
          },
          component: Cso
        }
      ]
    },
  ]
})

router.beforeEach((to, _from, next) => {
  if (to.fullPath === _from.fullPath) {
    return
  }
  next()
})
export default router
